package com.gp.gback.system.common.util;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * Created by dongsheng on 16/12/27.
 */
public class ListUtils {
    public static <T extends Comparable<T>> boolean compare(List<T> a, List<T> b) {
        if (a==null&&b==null)
            return true;
        else if (a==null||b==null)
            return false;
        if(a.size() != b.size())
            return false;
        Collections.sort(a);
        Collections.sort(b);
        for(int i=0;i<a.size();i++){
            if(!a.get(i).equals(b.get(i)))
                return false;
        }
        return true;
    }

    public static boolean equal(List a, List b){
        if (a==null&&b==null)
            return true;
        else if (a==null||b==null)
            return false;
        if(a.size() != b.size())
            return false;
        Collections.sort(a);
        Collections.sort(b);
        return Objects.equals(a,b);
    }
}
